home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1994 November / macformat-018.iso / Utility Spectacular / Developer / macgzip_022-src / macos / Posix / ThinkCPosix Sources / Open.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-07-26  |  459 b   |  21 lines  |  [TEXT/MPS ]

  1. /* $Id: $ */
  2.  
  3. /*
  4.  * This replacement for open() deals with 2 problems:
  5.  * (1) open() is often given with 3 arguments;
  6.  * (2) if an attempt is made to open a file :dirname:filename
  7.  *     and there is no directory dirnam,
  8.  *     open() returns ENOTDIR, where Unix would return ENOENT.
  9.  */
  10.  
  11. #include "ThinkCPosix.h"
  12.  
  13. int Open(char *filename, int mode, ...)
  14. {
  15.     int fd;
  16.     fd = open(filename, mode);
  17.     if (fd < 0 && errno == ENOTDIR)
  18.         errno = ENOENT;
  19.     return fd;
  20. }
  21.